From: Julian Sparber Date: Fri, 9 Feb 2024 11:55:44 +0000 (+0100) Subject: components/autorunManager: Use notification actions API X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~1^2~26 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6d6ac1372a933591985a84827c9882530ef1db7e;p=gnome-shell.git components/autorunManager: Use notification actions API Stop using custom buttons for notification actions. The only reason to use custom buttons was so that we could add icons next to the button label, if we really need the icons next to the label we can add icons to the notification API. By using the actions API we can ensure that buttons always look the same without additional work. Part-of: --- diff --git a/data/theme/gnome-shell-sass/_widgets.scss b/data/theme/gnome-shell-sass/_widgets.scss index ee16a7141..9eac62d95 100644 --- a/data/theme/gnome-shell-sass/_widgets.scss +++ b/data/theme/gnome-shell-sass/_widgets.scss @@ -21,7 +21,6 @@ @import 'widgets/ibus-popup'; // Notifications @import 'widgets/notifications'; -@import 'widgets/hotplug'; // Dialogs @import 'widgets/dialogs'; // OSDs diff --git a/data/theme/gnome-shell-sass/widgets/_hotplug.scss b/data/theme/gnome-shell-sass/widgets/_hotplug.scss deleted file mode 100644 index f20626b5e..000000000 --- a/data/theme/gnome-shell-sass/widgets/_hotplug.scss +++ /dev/null @@ -1,10 +0,0 @@ -// hotplug - -.hotplug-notification-item { - @extend %bubble_button; -} - -.hotplug-notification-item-icon { - icon-size: $medium_icon_size; - padding: 0 $base_margin; -} diff --git a/data/theme/meson.build b/data/theme/meson.build index 0d28efd03..8d01ae826 100644 --- a/data/theme/meson.build +++ b/data/theme/meson.build @@ -17,7 +17,6 @@ theme_sources = files([ 'gnome-shell-sass/widgets/_dash.scss', 'gnome-shell-sass/widgets/_dialogs.scss', 'gnome-shell-sass/widgets/_entries.scss', - 'gnome-shell-sass/widgets/_hotplug.scss', 'gnome-shell-sass/widgets/_ibus-popup.scss', 'gnome-shell-sass/widgets/_keyboard.scss', 'gnome-shell-sass/widgets/_login-lock.scss', diff --git a/js/ui/components/autorunManager.js b/js/ui/components/autorunManager.js index d2b69d67e..7e53f8396 100644 --- a/js/ui/components/autorunManager.js +++ b/js/ui/components/autorunManager.js @@ -1,9 +1,6 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; -import GObject from 'gi://GObject'; -import St from 'gi://St'; import * as GnomeSession from '../../misc/gnomeSession.js'; import * as MessageTray from '../messageTray.js'; @@ -190,7 +187,20 @@ class AutorunDispatcher { return; const source = MessageTray.getSystemSource(); - const notification = new AutorunNotification(source, mount, apps); + const notification = new MessageTray.Notification( + source, + mount.get_name() + ); + notification.connect('activate', () => { + const app = Gio.app_info_get_default_for_type('inode/directory', false); + startAppForMount(app, mount); + }); + apps.forEach(app => { + notification.addAction( + _('Open with %s').format(app.get_name()), + () => startAppForMount(app, mount) + ); + }); notification.connect('destroy', () => this._notifications.delete(mount)); this._notifications.set(mount, notification); source.showNotification(notification); @@ -238,70 +248,4 @@ class AutorunDispatcher { } } -const AutorunNotification = GObject.registerClass( -class AutorunNotification extends MessageTray.Notification { - constructor(source, mount, apps) { - super(source, mount.get_name()); - - this.gicon = mount.get_icon(); - - this._mount = mount; - this._apps = apps; - } - - createBanner() { - let banner = new MessageTray.NotificationBanner(this); - - this._apps.forEach(app => { - let actor = this._buttonForApp(app); - - if (actor) - banner.addButton(actor); - }); - - return banner; - } - - _buttonForApp(app) { - let box = new St.BoxLayout({ - x_expand: true, - x_align: Clutter.ActorAlign.START, - }); - const icon = new St.Icon({ - gicon: app.get_icon(), - style_class: 'hotplug-notification-item-icon', - }); - box.add_child(icon); - - let label = new St.Bin({ - child: new St.Label({ - text: _('Open with %s').format(app.get_name()), - y_align: Clutter.ActorAlign.CENTER, - }), - }); - box.add_child(label); - - const button = new St.Button({ - child: box, - x_expand: true, - button_mask: St.ButtonMask.ONE, - style_class: 'hotplug-notification-item button', - }); - - button.connect('clicked', () => { - startAppForMount(app, this._mount); - this.destroy(); - }); - - return button; - } - - activate() { - super.activate(); - - let app = Gio.app_info_get_default_for_type('inode/directory', false); - startAppForMount(app, this._mount); - } -}); - export {AutorunManager as Component};